<?php
//包含数据库配置文件
include '../../public/dbconfig.php';
//包含函数库文件
include '../../public/functions.php';
//调用函数 链接数据库
$link = con();

//接收用户要在哪个分区下添加版块
//分区id
$pid = $_POST['pid'];
//版块名称
$cname = $_POST['cname'];

//准备sql
$sql = "insert into cate(pid,cname)values('{$pid}','{$cname}')";

//执行sql
$res = mysqli_query($link,$sql);

//判断执行结果
if($res){
	echo '<script>alert("添加成功");window.location.href="list.php";</script>';
}else{
	echo '<script>alert("添加失败");window.location.href="list.php";</script>';
}
//关闭数据库链接
mysqli_close($link);